//
//  XSJHotEventTableCell.m
//  XSJ
//
//  Created by yuanyuan he on 2020/4/28.
//  Copyright © 2020 apple. All rights reserved.
//

#import "XSJHotEventTableCell.h"
#import <SDCycleScrollView.h>

@interface XSJHotEventTableCell ()<SDCycleScrollViewDelegate>

/* 轮播图 */
@property (strong , nonatomic)SDCycleScrollView *cycleScrollView;

@end

@implementation XSJHotEventTableCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.backgroundColor = [UIColor whiteColor];
    _cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(10, 10, LL_ScreenWidth-20, 100+30) delegate:self placeholderImage:nil];
    _cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
    _cycleScrollView.autoScrollTimeInterval = 3.0;
    _cycleScrollView.backgroundColor = [UIColor whiteColor];
    _cycleScrollView.layer.cornerRadius = 5.0f;
    _cycleScrollView.clipsToBounds = YES;
    [self addSubview:_cycleScrollView];
}

- (void)setImageUrls:(NSArray *)imageUrls
{
    _imageUrls = imageUrls;
    _cycleScrollView.placeholderImage = [UIImage imageNamed:@"default_160"];
    if (_imageUrls.count == 0) return;
    _cycleScrollView.imageURLStringsGroup = _imageUrls;
    
}

#pragma mark - 点击图片Bannar跳转
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"点击了%zd轮播图",index);
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(YCHHotEventTableCellDidClickAtIndex:)])
    {
        [self.delegate XSJHotEventTableCellDidClickAtIndex:index];
    }
}


@end
